<?
include("inc_security.php");

$redirect	= getValue("redirect", "str", "GET", base64_encode("listing.php"));
$redirect	= base64_decode($redirect);

$class_menu	= new menu();
$listAll		= $class_menu->getAllChild("categories_multi", "cat_id", "cat_parent_id", 0, 1, "cat_id,cat_name,cat_type", "cat_order ASC,cat_name ASC", "cat_has_child", 1);
unset($class_menu);

// Update cat_all_chil
$db_update	= new db_execute("UPDATE categories_multi SET cat_all_child = NULL");
unset($db_update);
$db_catRoot	= new db_query("SELECT cat_id, cat_name FROM categories_multi");
while($row	= mysql_fetch_array($db_catRoot->result)){
	$class_menu	= new menu();
	$listChild	= $class_menu->getListChild("categories_multi", "cat_id", "cat_parent_id", $row["cat_id"], "1=1", "cat_has_child");
	$listChild .= $row["cat_id"];
	echo $row["cat_name"] . ": " . $listChild . "<br>";
	unset($class_menu);
	$db_update	= new db_execute("UPDATE categories_multi SET cat_all_child = '" . $listChild . "' WHERE cat_id = " . $row["cat_id"]);
	unset($db_update);
}
unset($db_catRoot);
redirect($redirect);
?>